<?php

  include_once CORE_DIR.'/controllers/controller.php';

  class newsController extends Controller {
       public function newsController(&$target)
       {
           Controller::Controller($target);

           $id = (int)$this->target->arg(2);
           $this->main_object = new pages($id, $this->target);
       }

       public function mainAction()
       {
           $news_pages = array();
           // only news should be show
           $filter = array('type' => 'news');
           if ( $this->target->arg(1) ) {
               $filter['year(date)'] = (int)$this->target->arg(1);
           }
           if ( $this->target->arg(2) ) {
               $filter['month(date)'] = (int)$this->target->arg(2);
           }

           $news_pages = $this->main_object->select($count, $filter);
           $this->target->assign( 'news_pages', $news_pages );
       }

       public function viewAction()
       {
           $this->target->assign( 'view_news', $this->main_object);
       }
  }